output=open("lesson2-2.txt","w",encoding="utf-8")
content="""
#字符串编码及解码
>>> "不停".encode("utf-8")
b'\xe4\xb8\x8d\xe5\x81\x9c'
>>> b=b'\xe4\xb8\x8d\xe5\x81\x9c'
>>> b.decode("utf-8")
'不停'

#CRUD
1.C创建
>>> a="a"
>>> a=a+"b"
>>> a
'ab'
>>> a+="c"
>>> a
'abc'
2.R检索
>>> a="Happy new year"
>>> a[5]
' '
>>> a.find("p")
2
>>> a.index("v")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: substring not found
3.U更新
>>> a="happppy new year"
>>> a.replace("pppy","py")
'happy new year'
>>>
>>> a="happpy new year"
>>> a.replace("ppy","py")
'happy new year'
>>> a.split(" ")
['happppy', 'new', 'year']
>>> b=['happppy', 'new', 'year']
>>> ",".join(b)
'happppy,new,year'
4.D删除
>>> a=("         xjjxkk       ")
>>> a.strip()
'xjjxkk'

#格式化
#按传入参数默认顺序
a="滴"
b="哒"
print("雨:{},{}".format(a,b))
#按指定页参数索引
print("雨:{0},{1},{0},{1}".format(a,b))
#按关键词索引
print("雨:{c},{d},{c},{d}".format(c='哗',d='啦'))
#按变量
print(f"雨:{a},{b}")
#小数的表示
print("{:.3f}".format(2.3464587))
#%的表示
>>> "雨: %s %s"%("滴","哒")
'雨: 滴 哒'"""
output.write(content)
output.close()